package ru.kest.torrentwatchlist.web.imdb;

import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

/**
 * Created by Konstantin on 09.12.2014.
 */
@Component
public class ImdbService {

    public ImdbBean getRating(String id) {
        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
        converter.setSupportedMediaTypes(Collections.singletonList(MediaType.TEXT_HTML));

        RestTemplate restTemplate = new RestTemplate(Collections.singletonList(converter));
        return restTemplate.getForObject("http://www.omdbapi.com/?i=" + id + "&plot=short&r=json", ImdbBean.class);
    }

}
